/*
 * @Author: your name
 * @Date: 2020-10-13 09:11:50
 * @LastEditTime: 2020-10-14 17:15:20
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \nuxt-iview\nuxt.config.js
 */
module.exports = {
  // Target (https://go.nuxtjs.dev/config-target)
  target: 'static',
  mode: 'universal',
  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge,chrome=1' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { hid: 'renderer', name: 'renderer', content: `webkit` },
      { hid: 'viewport', name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no' },
      { hid: 'keywords', name: 'keywords', content: `NUXT,SSR` },
    ],
    script: [
      { src: '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  // server: {
  //   port: 8080, // default: 3000
  //   host: '0.0.0.0' // default: localhost,
  // },
  // Global CSS (https://go.nuxtjs.dev/config-css)
  css: [
    'iview/dist/styles/iview.css',
    '~/assets/css/reset.css',
    '~/assets/scss/common.scss',
    'swiper/swiper-bundle.css'
  ],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  plugins: [
    '@/plugins/iview',
    '~/plugins/i18n.js',
    { src: "~plugins/axios.js", ssr: true },
    { src: "@/plugins/vue-swiper", ssr: false }

  ],

  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: true,

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
  ],

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    '@nuxtjs/auth',
    "@nuxtjs/proxy",
    ['cookie-universal-nuxt', { parseJSON: false }]
  ],

  // Axios module configuration (https://go.nuxtjs.dev/config-axios)
  axios: {
    // 是否允许跨域
    proxy: true,
    baseURL:
      process.env._ENV === "production"
        ? "http://106.55.147.49:12005"
        : "http://localhost:3002/api/",
    withCredentials: true,
  },
  proxy: {
    '/api/': { target: 'http://localhost:3002', pathRewrite: {'^/api/': ''} }
  },

  // Build Configuration (https://go.nuxtjs.dev/config-build)
  build: {
    vendor: ['axios'], // 为防止重复打包
    transpile: [/^view-design/],
    extractCSS: {
      allChunks: true
    },
  },
  router: {              // customize nuxt.js router (vue-router).
    middleware: ['i18n']   // middleware all pages of the application
  },
  auth: {
    strategies: {
      local: {
        endpoints: {
          // login: { url: '/login/login', method: 'post', propertyName: 'token' },
          // logout: { url: '/auth/logout', method: 'post' },
          // user: { url: '/api/public/info', method: 'get', propertyName: 'data' }
        },
        // tokenRequired: true,
        // tokenType: 'bearer',
        // globalToken: true,
        // autoFetchUser: true
      }
    }
  }
}
